Release 10.1A: OpenEdge Development:
Java Open Clients
Providing meta data for INPUT TABLE-HANDLE parameters
For
TABLEparameters, the proxy calls thenext()andgetObject()methods to get the data that needs to be passed to the AppServer methods. For aTABLE-HANDLEparameter, the proxy must first call thegetMetaData()method to determine the format of the data.There are several alternatives for how
getMetaData()can supply the appropriate ResultSetMetaData object:
- Use a standard JDBC
ResultSet.If the input
ResultSetis a standard JDBCResultSetobtained from a query, the client application does not need to do anything. TheResultSetinstance already implements thegetMetaData()method and returns a standard ResultSetMetaData object.The proxy automatically maps SQL data types to Progress schema data types, as shown in Table C–5.
Note: Because a standardResultSetsupports a standard ResultSetMetaData object and not the Progress extension (ProResultSetMetaData), there can be no array fields.
Table C–5: Mapping between SQL and Progress 4GL schema data types for standard JDBC ResultSet SQL type Progress 4GL typeIf the
ResultSetcontains any other type, an exception is thrown.- Extend Progress’
InputResultSet.
- If the
ResultSetcontains a column type other than the types shown in Table C–5 and the column can be converted to a compliant type, implement your ownResultSetclass instead of passing thejava.sql.ResultSetdirectly as the parameter. For example, you can extendcom.progress.open4gl.InputResultSetwith your own class.When
getObject()is called on your class, it retrieves data from the corresponding standard object and converts the data before returning it to the proxy. When thegetMetaData()method is called, the implementation of your extended class must supply the appropriate meta data. To do this, the application must create and populate aProResultSetMetaDataImplobject, as described in the "ProResultSetMetaDataImpl class" section”.- If the application requires the resulting server-side temp-table to have an array field, this is another reason for you to extend the
InputResultSetclass. This time, the implementation of bothnext()andgetObject()call the standard instance’s corresponding methods to do the work. When thegetMetaData()method is called, however, the extending class must supply the required meta data, with the flattened schema view converted to the corresponding array field view. Again, to do this, the application must create and populate aProResultSetMetaDataImplobject, as described in the "ProResultSetMetaDataImpl class" section”.- Use the ResultSetMetaData from a previously obtained output
ResultSetunder the following condition:
- If the input
ResultSetis aResultSetthat was first obtained from the AppServer through anOUTPUTparameter, meta data can be obtained from that output set by callinggetMetaData()on it. You can think of this as anOUTPUT-INPUTTABLE-HANDLE, parameter even though it is output from one method call and input through another. TheResultSetMetaDataobject obtained from the outputResultSetcan then be provided whengetMetaData()is called for the inputResultSet.ProResultSetMetaDataImpl class
If the meta data for the input
ResultSetmust be supplied by code implemented in the client application, thegetMetaData()method must be implemented to return an instance of ResultSetMetaData. The recommended way to do this is to use thecom.progress.open4gl.ProResultSetMetaDataImplclass provided in the Open Client Toolkit. This is an implementation of theProResultSetMetaDatainterface, the same interface that is used by the client when getting output data.The only two methods of
ProResultSetMetaDataImplthe application must call are the constructor and theSetFieldMetaData()method, as follows:
The
SetFieldMetaData()method requires the following:
fieldNumbermust be between 1 and the number of fields.Namecannot be null.- The value of
Namemust be unique within the table.extentmust be zero or greater (forBLOBandCLOBfields, it must be zero or one).Note: The Open Client Toolkit class documentation in OpenEdgetypemust be one of the class constant values defined incom.progress.open4gl.Parameter. For more information, see the information on specifying data type meta data for temp-tables in Chapter 4, " Passing Parameters."-install-directory/java/doc/also describes these methods used by the client application for theProResultSetMetaDataImplclass.To pass a self-implemented
ResultSetfor aTABLE–HANDLEparameter, the application must:
- Create a new class that extends
com.progress.open4gl.InputResultSet, to provide access to the data to be passed to the server. This object’s implementation includes code fornext()andgetObject()(as for a static temp-table) and forgetMetaData(), which should return thecom.progress.open4gl.ProResultSetMetaDataImplinstance when called.- Create an instance of the class you created in Step 1.
- Create an instance of
com.progress.open4gl.ProResultSetMetaDataImpl.- Call
ProResultSetMetaDataImpl.setFieldMetaData()for each field of the table.- Make the
ProResultSetMetaDataImplinstance available to theInputResultSetobject. You can do this in any way you like, for example, by adding asetMetaData()method to yourInputResultSetimplementation.Note: Step 3 and Step 4 can be implemented in- Make the proxy method call passing the
com.progress.open4gl.InputResultSetinstance as the parameter.getMetaData()which eliminates the need for Step 5.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |